import {
  QueueBase,
} from './base';

export class Queue extends QueueBase {
  public constructor(...initials: any[]) {
    super(...initials);
  }

  public enqueue(element) {
    super.addBack(element);
  }

  public dequeue() {
    return super.removeFront();
  }

  public peak() {
    return super.peakFront();
  }
}

/**
 * complex of queue and stack
 */
export class DeQueue extends QueueBase {
  public constructor(...initials) {
    super(...initials);
  }

  public addFront(element) {
    if (this.isEmpty()) {
      this.addBack(element);
    } else {
      this.lowestCount--;
      this.items.set(this.lowestCount, element);
    }
  }

  public addBack(element) {
    super.addBack(element);
  }

  public removeFront() {
    return super.removeFront();
  }

  public removeBack() {
    return super.removeBack();
  }
  
  public peakFront() {
    return super.peakFront();
  }

  public peakBack() {
    return super.peakBack();
  }
}
